// import {Loading } from "element-plus";

//   let loading;
//   export function startLoading(text = "拼命加载中...") {
//     try {
//       loading = Loading({
//         lock: true,
//         text,
//         background: "rgba(0,0,0,0)",
//       });
//     } catch (error) {
//       console.error("Error creating loading instance:", error);
//     }
//   }
//   export function endLoading() {
//     if (loading) {
//       loading.close();
//     } else {
//       console.warn("Loading instance not found.");
//     }
//   }
import { ElLoading } from "element-plus"; // 确保使用 ElLoading
let loading;

export function startLoading(text = "拼命加载中...") {
  try {
    loading = ElLoading.service({
      lock: true,
      text,
      background: "rgba(0,0,0,0.7)", // 背景透明度
    });
  } catch (error) {
    console.error("Error creating loading instance:", error);
  }
}

export function endLoading() {
  if (loading) {
    loading.close();
  } else {
    console.warn("Loading instance not found.");
  }
}